package com.admin.action.boraction;

import com.admin.Action;
import com.admin.service.borservice.BorServiceImpl;
import com.pojo.BorrowerBean;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 管理员对用户注销申请进行操作
 */

public class UpdateCancelAction extends Action {

    @Override
    public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        PrintWriter out=response.getWriter();
        HttpSession session = request.getSession();
        if(session.getAttribute("adminInfo")==null){
            out.println("<script>parent.window.location.href='error.html';</script>");
            return;
        }

        BorServiceImpl service = new BorServiceImpl();
        BorrowerBean bor = new BorrowerBean();
        bor.setIsCancel(request.getParameter("isCancel"));
        bor.setUserId(Long.parseLong(request.getParameter("userId")));
        boolean bool = service.updateBorCancel(bor);
        out.print("{\"info\":\"" + bool + "\"}");
    }
}
